package com.inexas.cu.client.pipe;

import java.io.*;
import com.google.gwt.event.shared.*;

public abstract class AbstractResponse implements Serializable {
	private static final long serialVersionUID = -5418180932911967516L;
	private static final GwtEvent.Type<ResponseHandler<?>> TYPE = new GwtEvent.Type<ResponseHandler<?>>();
	private long requestId;
	protected String errorMessage;

	protected AbstractResponse() {
		// Serialization only
	}

	protected AbstractResponse(AbstractRequest request) {
		requestId = request.getRequestId();
	}

	// !todo this should be abstract
	protected GwtEvent.Type<ResponseHandler<?>> getAssociatedType() {
		return TYPE;
	}

	public long getRequestId() {
		return requestId;
	}

	/**
	 * No error message, no error
	 */
	public String getErrorMessage() {
		return errorMessage;
	}

	public void setErrorMessage(String errorMessage) {
		this.errorMessage = errorMessage;
	}

}
